﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmDm.
	/// </summary>
	public class frmMaubc : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button butKetthuc;
		private AccessData a;
		private DataTable dt=new DataTable();
		private DataTable dtc=new DataTable();
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button butMoi;
		private System.Windows.Forms.Button butSua;
		private System.Windows.Forms.Button butLuu;
		private System.Windows.Forms.Button butBoqua;
		private System.Windows.Forms.Button butHuy;
		private System.Windows.Forms.Label label3;
		private long l_id,l_idm;
		private int i_userid;
		private string user,sql;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ComboBox loai;
		private System.Windows.Forms.TextBox ct;
		private System.Windows.Forms.NumericUpDown ttm;
		private System.Windows.Forms.TextBox maso;
		private System.Windows.Forms.CheckBox indam;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox tminh;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox ghichu;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.TextBox sttm;
		private System.Windows.Forms.TextBox matg;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.TextBox tinhtg;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.TextBox dau;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox mcode;
		private System.Windows.Forms.CheckBox bc;
		private System.Windows.Forms.DataGrid dataGrid2;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.NumericUpDown tencot;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label label16;
		private System.Windows.Forms.Label label17;
		private System.Windows.Forms.Label label18;
		private System.Windows.Forms.Label label19;
		private System.Windows.Forms.Label label20;
		private System.Windows.Forms.Label label21;
		private System.Windows.Forms.Label label22;
		private System.Windows.Forms.Label label23;
		private System.Windows.Forms.Label label24;
		private System.Windows.Forms.Label label25;
		private System.Windows.Forms.Label label26;
		private System.Windows.Forms.Label label27;
		private System.Windows.Forms.Label label28;
		private System.Windows.Forms.NumericUpDown ttc;
		private System.Windows.Forms.TextBox nguondl;
		private System.Windows.Forms.TextBox fielddl;
		private System.Windows.Forms.TextBox dauc;
		private System.Windows.Forms.TextBox lk;
		private System.Windows.Forms.TextBox stk;
		private System.Windows.Forms.TextBox kmuc;
		private System.Windows.Forms.TextBox mtmuc;
		private System.Windows.Forms.TextBox nghiepvu;
		private System.Windows.Forms.TextBox tkno;
		private System.Windows.Forms.TextBox hoatdong;
		private System.Windows.Forms.TextBox tkco;
		private System.Windows.Forms.TextBox kmno;
		private System.Windows.Forms.TextBox mtmno;
		private System.Windows.Forms.TextBox kmco;
		private System.Windows.Forms.TextBox mtmco;
		private System.Windows.Forms.Button butThem;
		private System.Windows.Forms.Button butXoa;
		private System.Windows.Forms.Button butLoai;
		private System.Windows.Forms.ToolTip toolTip1;
		private System.ComponentModel.IContainer components;

		public frmMaubc(AccessData acc,int userid)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;i_userid=userid;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMaubc));
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.butKetthuc = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.ct = new System.Windows.Forms.TextBox();
			this.butMoi = new System.Windows.Forms.Button();
			this.butSua = new System.Windows.Forms.Button();
			this.butLuu = new System.Windows.Forms.Button();
			this.butBoqua = new System.Windows.Forms.Button();
			this.butHuy = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.ttm = new System.Windows.Forms.NumericUpDown();
			this.maso = new System.Windows.Forms.TextBox();
			this.indam = new System.Windows.Forms.CheckBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.loai = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.tminh = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.ghichu = new System.Windows.Forms.TextBox();
			this.label7 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.sttm = new System.Windows.Forms.TextBox();
			this.matg = new System.Windows.Forms.TextBox();
			this.label9 = new System.Windows.Forms.Label();
			this.tinhtg = new System.Windows.Forms.TextBox();
			this.label10 = new System.Windows.Forms.Label();
			this.dau = new System.Windows.Forms.TextBox();
			this.label11 = new System.Windows.Forms.Label();
			this.mcode = new System.Windows.Forms.TextBox();
			this.bc = new System.Windows.Forms.CheckBox();
			this.dataGrid2 = new System.Windows.Forms.DataGrid();
			this.ttc = new System.Windows.Forms.NumericUpDown();
			this.label12 = new System.Windows.Forms.Label();
			this.label13 = new System.Windows.Forms.Label();
			this.tencot = new System.Windows.Forms.NumericUpDown();
			this.label14 = new System.Windows.Forms.Label();
			this.nguondl = new System.Windows.Forms.TextBox();
			this.label15 = new System.Windows.Forms.Label();
			this.fielddl = new System.Windows.Forms.TextBox();
			this.dauc = new System.Windows.Forms.TextBox();
			this.label16 = new System.Windows.Forms.Label();
			this.lk = new System.Windows.Forms.TextBox();
			this.stk = new System.Windows.Forms.TextBox();
			this.label17 = new System.Windows.Forms.Label();
			this.label18 = new System.Windows.Forms.Label();
			this.kmuc = new System.Windows.Forms.TextBox();
			this.mtmuc = new System.Windows.Forms.TextBox();
			this.label19 = new System.Windows.Forms.Label();
			this.label20 = new System.Windows.Forms.Label();
			this.nghiepvu = new System.Windows.Forms.TextBox();
			this.tkno = new System.Windows.Forms.TextBox();
			this.label21 = new System.Windows.Forms.Label();
			this.label22 = new System.Windows.Forms.Label();
			this.hoatdong = new System.Windows.Forms.TextBox();
			this.tkco = new System.Windows.Forms.TextBox();
			this.label23 = new System.Windows.Forms.Label();
			this.label24 = new System.Windows.Forms.Label();
			this.kmno = new System.Windows.Forms.TextBox();
			this.mtmno = new System.Windows.Forms.TextBox();
			this.label25 = new System.Windows.Forms.Label();
			this.label26 = new System.Windows.Forms.Label();
			this.kmco = new System.Windows.Forms.TextBox();
			this.mtmco = new System.Windows.Forms.TextBox();
			this.label27 = new System.Windows.Forms.Label();
			this.label28 = new System.Windows.Forms.Label();
			this.butThem = new System.Windows.Forms.Button();
			this.butXoa = new System.Windows.Forms.Button();
			this.butLoai = new System.Windows.Forms.Button();
			this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.ttm)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.ttc)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.tencot)).BeginInit();
			this.SuspendLayout();
			// 
			// dataGrid1
			// 
			this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Lavender;
			this.dataGrid1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGrid1.BackColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.Control;
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dataGrid1.CaptionBackColor = System.Drawing.SystemColors.Control;
			this.dataGrid1.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid1.CaptionForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.FlatMode = true;
			this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
			this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
			this.dataGrid1.Location = new System.Drawing.Point(8, 8);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.RowHeaderWidth = 10;
			this.dataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid1.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.Size = new System.Drawing.Size(448, 352);
			this.dataGrid1.TabIndex = 39;
			this.dataGrid1.CurrentCellChanged += new System.EventHandler(this.dataGrid1_CurrentCellChanged);
			// 
			// butKetthuc
			// 
			this.butKetthuc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butKetthuc.Image = ((System.Drawing.Bitmap)(resources.GetObject("butKetthuc.Image")));
			this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butKetthuc.Location = new System.Drawing.Point(520, 490);
			this.butKetthuc.Name = "butKetthuc";
			this.butKetthuc.Size = new System.Drawing.Size(68, 25);
			this.butKetthuc.TabIndex = 38;
			this.butKetthuc.Text = "&Kết thúc";
			this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
			// 
			// label2
			// 
			this.label2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label2.Location = new System.Drawing.Point(3, 389);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 23);
			this.label2.TabIndex = 23;
			this.label2.Text = "Mã số :";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// ct
			// 
			this.ct.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.ct.BackColor = System.Drawing.SystemColors.HighlightText;
			this.ct.Enabled = false;
			this.ct.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ct.Location = new System.Drawing.Point(232, 366);
			this.ct.Name = "ct";
			this.ct.Size = new System.Drawing.Size(224, 21);
			this.ct.TabIndex = 4;
			this.ct.Text = "";
			this.ct.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			this.ct.Validated += new System.EventHandler(this.ct_Validated);
			// 
			// butMoi
			// 
			this.butMoi.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butMoi.Image = ((System.Drawing.Bitmap)(resources.GetObject("butMoi.Image")));
			this.butMoi.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butMoi.Location = new System.Drawing.Point(205, 490);
			this.butMoi.Name = "butMoi";
			this.butMoi.Size = new System.Drawing.Size(60, 25);
			this.butMoi.TabIndex = 35;
			this.butMoi.Text = "    &Mới";
			this.butMoi.Click += new System.EventHandler(this.butMoi_Click);
			// 
			// butSua
			// 
			this.butSua.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butSua.Image = ((System.Drawing.Bitmap)(resources.GetObject("butSua.Image")));
			this.butSua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butSua.Location = new System.Drawing.Point(268, 490);
			this.butSua.Name = "butSua";
			this.butSua.Size = new System.Drawing.Size(60, 25);
			this.butSua.TabIndex = 36;
			this.butSua.Text = "     &Sửa";
			this.butSua.Click += new System.EventHandler(this.butSua_Click);
			// 
			// butLuu
			// 
			this.butLuu.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butLuu.Enabled = false;
			this.butLuu.Image = ((System.Drawing.Bitmap)(resources.GetObject("butLuu.Image")));
			this.butLuu.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butLuu.Location = new System.Drawing.Point(331, 490);
			this.butLuu.Name = "butLuu";
			this.butLuu.Size = new System.Drawing.Size(60, 25);
			this.butLuu.TabIndex = 33;
			this.butLuu.Text = "    &Lưu";
			this.butLuu.Click += new System.EventHandler(this.butLuu_Click);
			// 
			// butBoqua
			// 
			this.butBoqua.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butBoqua.Enabled = false;
			this.butBoqua.Image = ((System.Drawing.Bitmap)(resources.GetObject("butBoqua.Image")));
			this.butBoqua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butBoqua.Location = new System.Drawing.Point(394, 490);
			this.butBoqua.Name = "butBoqua";
			this.butBoqua.Size = new System.Drawing.Size(60, 25);
			this.butBoqua.TabIndex = 34;
			this.butBoqua.Text = "&Bỏ qua";
			this.butBoqua.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butBoqua.Click += new System.EventHandler(this.butBoqua_Click);
			// 
			// butHuy
			// 
			this.butHuy.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butHuy.Image = ((System.Drawing.Bitmap)(resources.GetObject("butHuy.Image")));
			this.butHuy.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butHuy.Location = new System.Drawing.Point(457, 490);
			this.butHuy.Name = "butHuy";
			this.butHuy.Size = new System.Drawing.Size(60, 25);
			this.butHuy.TabIndex = 37;
			this.butHuy.Text = "     &Hủy";
			this.butHuy.Click += new System.EventHandler(this.butHuy_Click);
			// 
			// label3
			// 
			this.label3.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label3.Location = new System.Drawing.Point(35, 366);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(24, 23);
			this.label3.TabIndex = 24;
			this.label3.Text = "TT :";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// ttm
			// 
			this.ttm.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.ttm.Enabled = false;
			this.ttm.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ttm.Location = new System.Drawing.Point(56, 366);
			this.ttm.Maximum = new System.Decimal(new int[] {
																500,
																0,
																0,
																0});
			this.ttm.Name = "ttm";
			this.ttm.Size = new System.Drawing.Size(40, 21);
			this.ttm.TabIndex = 2;
			this.ttm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// maso
			// 
			this.maso.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.maso.BackColor = System.Drawing.SystemColors.HighlightText;
			this.maso.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.maso.Enabled = false;
			this.maso.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.maso.Location = new System.Drawing.Point(56, 392);
			this.maso.MaxLength = 10;
			this.maso.Name = "maso";
			this.maso.Size = new System.Drawing.Size(120, 21);
			this.maso.TabIndex = 5;
			this.maso.Text = "";
			this.maso.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// indam
			// 
			this.indam.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.indam.Enabled = false;
			this.indam.Location = new System.Drawing.Point(392, 416);
			this.indam.Name = "indam";
			this.indam.Size = new System.Drawing.Size(64, 16);
			this.indam.TabIndex = 8;
			this.indam.Text = "In đậm";
			this.indam.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label4
			// 
			this.label4.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label4.Location = new System.Drawing.Point(168, 366);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 23);
			this.label4.TabIndex = 29;
			this.label4.Text = "Chỉ tiêu :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(-8, 3);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(48, 23);
			this.label6.TabIndex = 0;
			this.label6.Text = "Loại :";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// loai
			// 
			this.loai.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.loai.BackColor = System.Drawing.SystemColors.HighlightText;
			this.loai.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.loai.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.loai.Location = new System.Drawing.Point(40, 3);
			this.loai.Name = "loai";
			this.loai.Size = new System.Drawing.Size(720, 21);
			this.loai.TabIndex = 1;
			this.loai.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			this.loai.SelectedIndexChanged += new System.EventHandler(this.loai_SelectedIndexChanged);
			// 
			// label1
			// 
			this.label1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label1.Location = new System.Drawing.Point(152, 389);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(80, 23);
			this.label1.TabIndex = 30;
			this.label1.Text = "T. minh :";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// tminh
			// 
			this.tminh.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tminh.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tminh.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.tminh.Enabled = false;
			this.tminh.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tminh.Location = new System.Drawing.Point(232, 389);
			this.tminh.Name = "tminh";
			this.tminh.Size = new System.Drawing.Size(224, 21);
			this.tminh.TabIndex = 6;
			this.tminh.Text = "";
			this.tminh.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label5
			// 
			this.label5.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label5.Location = new System.Drawing.Point(-21, 412);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(80, 23);
			this.label5.TabIndex = 32;
			this.label5.Text = "Ghi chú :";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// ghichu
			// 
			this.ghichu.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.ghichu.BackColor = System.Drawing.SystemColors.HighlightText;
			this.ghichu.Enabled = false;
			this.ghichu.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ghichu.Location = new System.Drawing.Point(56, 412);
			this.ghichu.Name = "ghichu";
			this.ghichu.Size = new System.Drawing.Size(328, 21);
			this.ghichu.TabIndex = 7;
			this.ghichu.Text = "";
			this.ghichu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label7
			// 
			this.label7.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label7.Location = new System.Drawing.Point(-5, 435);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(64, 23);
			this.label7.TabIndex = 34;
			this.label7.Text = "Mã T.Gian :";
			this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label8
			// 
			this.label8.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label8.Location = new System.Drawing.Point(88, 366);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(40, 23);
			this.label8.TabIndex = 35;
			this.label8.Text = "STT :";
			this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// sttm
			// 
			this.sttm.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sttm.BackColor = System.Drawing.SystemColors.HighlightText;
			this.sttm.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.sttm.Enabled = false;
			this.sttm.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.sttm.Location = new System.Drawing.Point(128, 366);
			this.sttm.MaxLength = 3;
			this.sttm.Name = "sttm";
			this.sttm.Size = new System.Drawing.Size(48, 21);
			this.sttm.TabIndex = 3;
			this.sttm.Text = "";
			this.sttm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// matg
			// 
			this.matg.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.matg.BackColor = System.Drawing.SystemColors.HighlightText;
			this.matg.Enabled = false;
			this.matg.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.matg.Location = new System.Drawing.Point(56, 435);
			this.matg.Name = "matg";
			this.matg.Size = new System.Drawing.Size(104, 21);
			this.matg.TabIndex = 9;
			this.matg.Text = "";
			this.matg.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label9
			// 
			this.label9.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label9.Location = new System.Drawing.Point(160, 435);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(72, 23);
			this.label9.TabIndex = 38;
			this.label9.Text = "Tính T.Gian :";
			this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// tinhtg
			// 
			this.tinhtg.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.tinhtg.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tinhtg.Enabled = false;
			this.tinhtg.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tinhtg.Location = new System.Drawing.Point(232, 435);
			this.tinhtg.Name = "tinhtg";
			this.tinhtg.Size = new System.Drawing.Size(224, 21);
			this.tinhtg.TabIndex = 10;
			this.tinhtg.Text = "";
			this.tinhtg.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			this.tinhtg.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tinhtg_KeyPress);
			// 
			// label10
			// 
			this.label10.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label10.Location = new System.Drawing.Point(-5, 458);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(64, 23);
			this.label10.TabIndex = 40;
			this.label10.Text = "Dấu :";
			this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// dau
			// 
			this.dau.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.dau.BackColor = System.Drawing.SystemColors.HighlightText;
			this.dau.Enabled = false;
			this.dau.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dau.Location = new System.Drawing.Point(56, 458);
			this.dau.Name = "dau";
			this.dau.Size = new System.Drawing.Size(104, 21);
			this.dau.TabIndex = 11;
			this.dau.Text = "";
			this.dau.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			this.dau.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.dau_KeyPress);
			// 
			// label11
			// 
			this.label11.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label11.Location = new System.Drawing.Point(160, 458);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(72, 23);
			this.label11.TabIndex = 42;
			this.label11.Text = "Mã code :";
			this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// mcode
			// 
			this.mcode.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.mcode.BackColor = System.Drawing.SystemColors.HighlightText;
			this.mcode.Enabled = false;
			this.mcode.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.mcode.Location = new System.Drawing.Point(232, 458);
			this.mcode.Name = "mcode";
			this.mcode.Size = new System.Drawing.Size(152, 21);
			this.mcode.TabIndex = 12;
			this.mcode.Text = "";
			this.mcode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// bc
			// 
			this.bc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.bc.Enabled = false;
			this.bc.Location = new System.Drawing.Point(392, 462);
			this.bc.Name = "bc";
			this.bc.Size = new System.Drawing.Size(72, 16);
			this.bc.TabIndex = 13;
			this.bc.Text = "Báo cáo";
			this.bc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// dataGrid2
			// 
			this.dataGrid2.AlternatingBackColor = System.Drawing.Color.Lavender;
			this.dataGrid2.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGrid2.BackColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid2.BackgroundColor = System.Drawing.SystemColors.Control;
			this.dataGrid2.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dataGrid2.CaptionBackColor = System.Drawing.SystemColors.Control;
			this.dataGrid2.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid2.CaptionForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid2.DataMember = "";
			this.dataGrid2.FlatMode = true;
			this.dataGrid2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid2.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid2.GridLineColor = System.Drawing.Color.Gainsboro;
			this.dataGrid2.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
			this.dataGrid2.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid2.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid2.LinkColor = System.Drawing.Color.Teal;
			this.dataGrid2.Location = new System.Drawing.Point(464, 8);
			this.dataGrid2.Name = "dataGrid2";
			this.dataGrid2.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
			this.dataGrid2.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid2.ReadOnly = true;
			this.dataGrid2.RowHeaderWidth = 10;
			this.dataGrid2.SelectionBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid2.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid2.Size = new System.Drawing.Size(320, 288);
			this.dataGrid2.TabIndex = 40;
			this.dataGrid2.CurrentCellChanged += new System.EventHandler(this.dataGrid2_CurrentCellChanged);
			// 
			// ttc
			// 
			this.ttc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.ttc.Enabled = false;
			this.ttc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ttc.Location = new System.Drawing.Point(504, 298);
			this.ttc.Maximum = new System.Decimal(new int[] {
																500,
																0,
																0,
																0});
			this.ttc.Name = "ttc";
			this.ttc.Size = new System.Drawing.Size(40, 21);
			this.ttc.TabIndex = 14;
			this.ttc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label12
			// 
			this.label12.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label12.Location = new System.Drawing.Point(466, 298);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(40, 23);
			this.label12.TabIndex = 47;
			this.label12.Text = "STT :";
			this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label13
			// 
			this.label13.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label13.Location = new System.Drawing.Point(536, 298);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(48, 23);
			this.label13.TabIndex = 48;
			this.label13.Text = "Số cột :";
			this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// tencot
			// 
			this.tencot.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.tencot.Enabled = false;
			this.tencot.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tencot.Location = new System.Drawing.Point(584, 298);
			this.tencot.Name = "tencot";
			this.tencot.Size = new System.Drawing.Size(40, 21);
			this.tencot.TabIndex = 15;
			this.tencot.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label14
			// 
			this.label14.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label14.Location = new System.Drawing.Point(609, 298);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(64, 23);
			this.label14.TabIndex = 50;
			this.label14.Text = "Nguồn :";
			this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// nguondl
			// 
			this.nguondl.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.nguondl.BackColor = System.Drawing.SystemColors.HighlightText;
			this.nguondl.Enabled = false;
			this.nguondl.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.nguondl.Location = new System.Drawing.Point(673, 298);
			this.nguondl.Name = "nguondl";
			this.nguondl.Size = new System.Drawing.Size(112, 21);
			this.nguondl.TabIndex = 16;
			this.nguondl.Text = "";
			this.nguondl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label15
			// 
			this.label15.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label15.Location = new System.Drawing.Point(442, 321);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(64, 23);
			this.label15.TabIndex = 52;
			this.label15.Text = "Dữ liệu :";
			this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// fielddl
			// 
			this.fielddl.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.fielddl.BackColor = System.Drawing.SystemColors.HighlightText;
			this.fielddl.Enabled = false;
			this.fielddl.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.fielddl.Location = new System.Drawing.Point(504, 321);
			this.fielddl.Name = "fielddl";
			this.fielddl.Size = new System.Drawing.Size(120, 21);
			this.fielddl.TabIndex = 17;
			this.fielddl.Text = "";
			this.fielddl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// dauc
			// 
			this.dauc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.dauc.BackColor = System.Drawing.SystemColors.HighlightText;
			this.dauc.Enabled = false;
			this.dauc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dauc.Location = new System.Drawing.Point(673, 321);
			this.dauc.Name = "dauc";
			this.dauc.Size = new System.Drawing.Size(112, 21);
			this.dauc.TabIndex = 18;
			this.dauc.Text = "";
			this.dauc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			this.dauc.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.dauc_KeyPress);
			// 
			// label16
			// 
			this.label16.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label16.Location = new System.Drawing.Point(609, 321);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(64, 23);
			this.label16.TabIndex = 54;
			this.label16.Text = "Dấu :";
			this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lk
			// 
			this.lk.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.lk.BackColor = System.Drawing.SystemColors.HighlightText;
			this.lk.Enabled = false;
			this.lk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lk.Location = new System.Drawing.Point(504, 344);
			this.lk.Name = "lk";
			this.lk.Size = new System.Drawing.Size(120, 21);
			this.lk.TabIndex = 19;
			this.lk.Text = "";
			this.lk.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// stk
			// 
			this.stk.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.stk.BackColor = System.Drawing.SystemColors.HighlightText;
			this.stk.Enabled = false;
			this.stk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.stk.Location = new System.Drawing.Point(673, 344);
			this.stk.Name = "stk";
			this.stk.Size = new System.Drawing.Size(112, 21);
			this.stk.TabIndex = 20;
			this.stk.Text = "";
			this.stk.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label17
			// 
			this.label17.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label17.Location = new System.Drawing.Point(609, 344);
			this.label17.Name = "label17";
			this.label17.Size = new System.Drawing.Size(64, 23);
			this.label17.TabIndex = 58;
			this.label17.Text = "STK :";
			this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label18
			// 
			this.label18.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label18.Location = new System.Drawing.Point(474, 344);
			this.label18.Name = "label18";
			this.label18.Size = new System.Drawing.Size(32, 23);
			this.label18.TabIndex = 56;
			this.label18.Text = "LK :";
			this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmuc
			// 
			this.kmuc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.kmuc.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmuc.Enabled = false;
			this.kmuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmuc.Location = new System.Drawing.Point(504, 367);
			this.kmuc.Name = "kmuc";
			this.kmuc.Size = new System.Drawing.Size(120, 21);
			this.kmuc.TabIndex = 21;
			this.kmuc.Text = "";
			this.kmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// mtmuc
			// 
			this.mtmuc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.mtmuc.BackColor = System.Drawing.SystemColors.HighlightText;
			this.mtmuc.Enabled = false;
			this.mtmuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.mtmuc.Location = new System.Drawing.Point(673, 367);
			this.mtmuc.Name = "mtmuc";
			this.mtmuc.Size = new System.Drawing.Size(112, 21);
			this.mtmuc.TabIndex = 22;
			this.mtmuc.Text = "";
			this.mtmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label19
			// 
			this.label19.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label19.Location = new System.Drawing.Point(609, 367);
			this.label19.Name = "label19";
			this.label19.Size = new System.Drawing.Size(64, 23);
			this.label19.TabIndex = 62;
			this.label19.Text = "MTMục :";
			this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label20
			// 
			this.label20.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label20.Location = new System.Drawing.Point(442, 367);
			this.label20.Name = "label20";
			this.label20.Size = new System.Drawing.Size(64, 23);
			this.label20.TabIndex = 60;
			this.label20.Text = "K.Mục :";
			this.label20.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// nghiepvu
			// 
			this.nghiepvu.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.nghiepvu.BackColor = System.Drawing.SystemColors.HighlightText;
			this.nghiepvu.Enabled = false;
			this.nghiepvu.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.nghiepvu.Location = new System.Drawing.Point(504, 390);
			this.nghiepvu.Name = "nghiepvu";
			this.nghiepvu.Size = new System.Drawing.Size(120, 21);
			this.nghiepvu.TabIndex = 23;
			this.nghiepvu.Text = "";
			this.nghiepvu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// tkno
			// 
			this.tkno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.tkno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tkno.Enabled = false;
			this.tkno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tkno.Location = new System.Drawing.Point(504, 413);
			this.tkno.Name = "tkno";
			this.tkno.Size = new System.Drawing.Size(120, 21);
			this.tkno.TabIndex = 25;
			this.tkno.Text = "";
			this.tkno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label21
			// 
			this.label21.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label21.Location = new System.Drawing.Point(466, 413);
			this.label21.Name = "label21";
			this.label21.Size = new System.Drawing.Size(40, 23);
			this.label21.TabIndex = 66;
			this.label21.Text = "TK nợ :";
			this.label21.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label22
			// 
			this.label22.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label22.Location = new System.Drawing.Point(442, 390);
			this.label22.Name = "label22";
			this.label22.Size = new System.Drawing.Size(64, 23);
			this.label22.TabIndex = 64;
			this.label22.Text = "N.vụ :";
			this.label22.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// hoatdong
			// 
			this.hoatdong.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.hoatdong.BackColor = System.Drawing.SystemColors.HighlightText;
			this.hoatdong.Enabled = false;
			this.hoatdong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoatdong.Location = new System.Drawing.Point(673, 390);
			this.hoatdong.Name = "hoatdong";
			this.hoatdong.Size = new System.Drawing.Size(112, 21);
			this.hoatdong.TabIndex = 24;
			this.hoatdong.Text = "";
			this.hoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// tkco
			// 
			this.tkco.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.tkco.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tkco.Enabled = false;
			this.tkco.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tkco.Location = new System.Drawing.Point(673, 436);
			this.tkco.Name = "tkco";
			this.tkco.Size = new System.Drawing.Size(112, 21);
			this.tkco.TabIndex = 28;
			this.tkco.Text = "";
			this.tkco.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label23
			// 
			this.label23.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label23.Location = new System.Drawing.Point(609, 436);
			this.label23.Name = "label23";
			this.label23.Size = new System.Drawing.Size(64, 23);
			this.label23.TabIndex = 74;
			this.label23.Text = "TK có :";
			this.label23.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label24
			// 
			this.label24.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label24.Location = new System.Drawing.Point(609, 390);
			this.label24.Name = "label24";
			this.label24.Size = new System.Drawing.Size(64, 23);
			this.label24.TabIndex = 72;
			this.label24.Text = "H.động :";
			this.label24.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmno
			// 
			this.kmno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.kmno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmno.Enabled = false;
			this.kmno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmno.Location = new System.Drawing.Point(673, 413);
			this.kmno.Name = "kmno";
			this.kmno.Size = new System.Drawing.Size(112, 21);
			this.kmno.TabIndex = 26;
			this.kmno.Text = "";
			this.kmno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// mtmno
			// 
			this.mtmno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.mtmno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.mtmno.Enabled = false;
			this.mtmno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.mtmno.Location = new System.Drawing.Point(504, 436);
			this.mtmno.Name = "mtmno";
			this.mtmno.Size = new System.Drawing.Size(120, 21);
			this.mtmno.TabIndex = 27;
			this.mtmno.Text = "";
			this.mtmno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label25
			// 
			this.label25.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label25.Location = new System.Drawing.Point(442, 436);
			this.label25.Name = "label25";
			this.label25.Size = new System.Drawing.Size(64, 23);
			this.label25.TabIndex = 70;
			this.label25.Text = "MTM Nợ :";
			this.label25.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label26
			// 
			this.label26.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label26.Location = new System.Drawing.Point(609, 413);
			this.label26.Name = "label26";
			this.label26.Size = new System.Drawing.Size(64, 23);
			this.label26.TabIndex = 68;
			this.label26.Text = "KM Nợ :";
			this.label26.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmco
			// 
			this.kmco.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.kmco.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmco.Enabled = false;
			this.kmco.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmco.Location = new System.Drawing.Point(504, 459);
			this.kmco.Name = "kmco";
			this.kmco.Size = new System.Drawing.Size(120, 21);
			this.kmco.TabIndex = 29;
			this.kmco.Text = "";
			this.kmco.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// mtmco
			// 
			this.mtmco.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.mtmco.BackColor = System.Drawing.SystemColors.HighlightText;
			this.mtmco.Enabled = false;
			this.mtmco.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.mtmco.Location = new System.Drawing.Point(673, 459);
			this.mtmco.Name = "mtmco";
			this.mtmco.Size = new System.Drawing.Size(112, 21);
			this.mtmco.TabIndex = 30;
			this.mtmco.Text = "";
			this.mtmco.KeyDown += new System.Windows.Forms.KeyEventHandler(this.stt_KeyDown);
			// 
			// label27
			// 
			this.label27.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label27.Location = new System.Drawing.Point(609, 459);
			this.label27.Name = "label27";
			this.label27.Size = new System.Drawing.Size(64, 23);
			this.label27.TabIndex = 78;
			this.label27.Text = "MTM có :";
			this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label28
			// 
			this.label28.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label28.Location = new System.Drawing.Point(442, 459);
			this.label28.Name = "label28";
			this.label28.Size = new System.Drawing.Size(64, 23);
			this.label28.TabIndex = 76;
			this.label28.Text = "KM Có :";
			this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// butThem
			// 
			this.butThem.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.butThem.Image = ((System.Drawing.Bitmap)(resources.GetObject("butThem.Image")));
			this.butThem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butThem.Location = new System.Drawing.Point(664, 485);
			this.butThem.Name = "butThem";
			this.butThem.Size = new System.Drawing.Size(60, 23);
			this.butThem.TabIndex = 31;
			this.butThem.Text = "&Thêm";
			this.butThem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butThem.Visible = false;
			this.butThem.Click += new System.EventHandler(this.butThem_Click);
			// 
			// butXoa
			// 
			this.butXoa.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.butXoa.Image = ((System.Drawing.Bitmap)(resources.GetObject("butXoa.Image")));
			this.butXoa.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butXoa.Location = new System.Drawing.Point(726, 485);
			this.butXoa.Name = "butXoa";
			this.butXoa.Size = new System.Drawing.Size(60, 23);
			this.butXoa.TabIndex = 32;
			this.butXoa.Text = "      &Xóa";
			this.butXoa.Visible = false;
			this.butXoa.Click += new System.EventHandler(this.butXoa_Click);
			// 
			// butLoai
			// 
			this.butLoai.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			this.butLoai.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.butLoai.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butLoai.Location = new System.Drawing.Point(762, 2);
			this.butLoai.Name = "butLoai";
			this.butLoai.Size = new System.Drawing.Size(24, 21);
			this.butLoai.TabIndex = 82;
			this.butLoai.Text = "...";
			this.toolTip1.SetToolTip(this.butLoai, "Danh mục mẫu báo cáo");
			this.butLoai.Click += new System.EventHandler(this.butLoai_Click);
			// 
			// frmMaubc
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.mtmno,
																		  this.tkno,
																		  this.nghiepvu,
																		  this.butLoai,
																		  this.butXoa,
																		  this.butThem,
																		  this.bc,
																		  this.kmco,
																		  this.mtmco,
																		  this.label27,
																		  this.label28,
																		  this.tinhtg,
																		  this.tminh,
																		  this.ct,
																		  this.hoatdong,
																		  this.tkco,
																		  this.label23,
																		  this.label24,
																		  this.kmno,
																		  this.label25,
																		  this.label26,
																		  this.label21,
																		  this.label22,
																		  this.kmuc,
																		  this.mtmuc,
																		  this.label19,
																		  this.label20,
																		  this.lk,
																		  this.stk,
																		  this.label17,
																		  this.fielddl,
																		  this.dauc,
																		  this.label16,
																		  this.ttc,
																		  this.label15,
																		  this.nguondl,
																		  this.tencot,
																		  this.label14,
																		  this.label13,
																		  this.label12,
																		  this.maso,
																		  this.mcode,
																		  this.label11,
																		  this.dau,
																		  this.label10,
																		  this.label9,
																		  this.matg,
																		  this.ttm,
																		  this.sttm,
																		  this.label8,
																		  this.label7,
																		  this.ghichu,
																		  this.label5,
																		  this.label1,
																		  this.indam,
																		  this.loai,
																		  this.label6,
																		  this.label4,
																		  this.label3,
																		  this.butHuy,
																		  this.butBoqua,
																		  this.butLuu,
																		  this.butSua,
																		  this.butMoi,
																		  this.label2,
																		  this.butKetthuc,
																		  this.dataGrid1,
																		  this.dataGrid2,
																		  this.label18});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.KeyPreview = true;
			this.Name = "frmMaubc";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Lập công thức báo cáo tài chính";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMaubc_KeyDown);
			this.Load += new System.EventHandler(this.frmMaubc_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.ttm)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.ttc)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.tencot)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmMaubc_Load(object sender, System.EventArgs e)
		{
			user=a.user;
			loai.DisplayMember="TEN";
			loai.ValueMember="ID";			
			load_maubc();

			load_grid();
			ref_text();
			AddGridTableStyle();			
			AddGridTableStyle1();
			
		}

		private void load_maubc()
		{
			loai.DataSource=a.get_data("select * from a_dmmaubc order by tt").Tables[0];
		}

		private void load_grid()
		{
			sql="select * from a_maubc ";
			sql+=" where idm="+((loai.SelectedIndex!=-1)?long.Parse(loai.SelectedValue.ToString()):0);
			sql+=" order by mcode";
			dt=a.get_data(sql).Tables[0];
			dataGrid1.DataSource=dt;			
		}

		private void load_ct()
		{
			sql="select * from a_congthuc ";
			sql+=" where idbc="+l_id;
			sql+=" order by tt";
			dtc=a.get_data(sql).Tables[0];
			dataGrid2.DataSource=dtc;
			ref_text1();
		}

		private void AddGridTableStyle()
		{
			DataGridTableStyle ts =new DataGridTableStyle();
			ts.MappingName = dt.TableName;
			ts.AlternatingBackColor = Color.Beige;
			ts.BackColor = Color.GhostWhite;
			ts.ForeColor = Color.MidnightBlue;
			ts.GridLineColor = Color.RoyalBlue;
			ts.HeaderBackColor = Color.MidnightBlue;
			ts.HeaderForeColor = Color.Lavender;
			ts.SelectionBackColor = Color.Teal;
			ts.SelectionForeColor = Color.PaleGreen;
			ts.ReadOnly=false;
			ts.RowHeaderWidth=10;
						
			DataGridTextBoxColumn TextCol=new DataGridTextBoxColumn();			
			TextCol.MappingName = "id";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "stt";
			TextCol.HeaderText = "STT";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "ct";
			TextCol.HeaderText = "Chỉ tiêu";
			TextCol.Width = 300;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "maso";
			TextCol.HeaderText = "Mã số";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tminh";
			TextCol.HeaderText = "Thuyết minh";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "ghichu";
			TextCol.HeaderText = "Ghi chú";
			TextCol.Width = 200;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "indam";
			TextCol.HeaderText = "In đậm";
			TextCol.Width = 40;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "matg";
			TextCol.HeaderText = "Mã T.Gian";
			TextCol.Width = 70;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tinhtg";
			TextCol.HeaderText = "Tính T.Gian";
			TextCol.Width = 80;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "dau";
			TextCol.HeaderText = "Dấu";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "mcode";
			TextCol.HeaderText = "Mã Code";
			TextCol.Width = 70;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "bc";
			TextCol.HeaderText = "Báo cáo";
			TextCol.Width = 45;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);
		}

		private void AddGridTableStyle1()
		{
			DataGridTableStyle ts =new DataGridTableStyle();
			ts.MappingName = dtc.TableName;
			ts.AlternatingBackColor = Color.Beige;
			ts.BackColor = Color.GhostWhite;
			ts.ForeColor = Color.MidnightBlue;
			ts.GridLineColor = Color.RoyalBlue;
			ts.HeaderBackColor = Color.MidnightBlue;
			ts.HeaderForeColor = Color.Lavender;
			ts.SelectionBackColor = Color.Teal;
			ts.SelectionForeColor = Color.PaleGreen;
			ts.ReadOnly=false;
			ts.RowHeaderWidth=10;
						
			DataGridTextBoxColumn TextCol=new DataGridTextBoxColumn();			
			TextCol.MappingName = "id";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tencot";
			TextCol.HeaderText = "Cột";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "nguondl";
			TextCol.HeaderText = "Nguồn";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "fielddl";
			TextCol.HeaderText = "Dữ liệu";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "dau";
			TextCol.HeaderText = "Dấu";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "lk";
			TextCol.HeaderText = "Loại khoản";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "stk";
			TextCol.HeaderText = "STK";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "kmuc";
			TextCol.HeaderText = "Khoản mục";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "mtmuc";
			TextCol.HeaderText = "MT Mục";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "nghiepvu";
			TextCol.HeaderText = "Nghiệp vụ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "hoatdong";
			TextCol.HeaderText = "Hoạt động";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tkno";
			TextCol.HeaderText = "TK Nợ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "kmno";
			TextCol.HeaderText = "KM Nợ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "mtmno";
			TextCol.HeaderText = "MTM Nợ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tkco";
			TextCol.HeaderText = "TK Có";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "kmco";
			TextCol.HeaderText = "KM Có";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "mtmco";
			TextCol.HeaderText = "MTM Có";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			a.close();System.GC.Collect();this.Close();
		}

		private void ena_object(bool ena)
		{
			dataGrid1.Enabled=!ena;			
			indam.Enabled=bc.Enabled=maso.Enabled=ena;
			sttm.Enabled=ttm.Enabled=ct.Enabled=maso.Enabled=tminh.Enabled=ghichu.Enabled=matg.Enabled=tinhtg.Enabled=dau.Enabled=mcode.Enabled=ena;
			ttc.Enabled=tencot.Enabled=nguondl.Enabled=fielddl.Enabled=dauc.Enabled=lk.Enabled=stk.Enabled=kmuc.Enabled=mtmuc.Enabled=nghiepvu.Enabled=hoatdong.Enabled=tkno.Enabled=kmno.Enabled=mtmno.Enabled=tkco.Enabled=kmco.Enabled=mtmco.Enabled=ena;
			loai.Enabled=butMoi.Enabled=butSua.Enabled=!ena;
			butLuu.Enabled=butBoqua.Enabled=butThem.Visible=butXoa.Visible=ena;
			butHuy.Enabled=butKetthuc.Enabled=!ena;
		}

		private void butMoi_Click(object sender, System.EventArgs e)
		{
			try
			{
				ttm.Value=decimal.Parse(a.get_data("select max(tt) from "+user+".a_maubc where idm="+long.Parse(loai.SelectedValue.ToString())).Tables[0].Rows[0][0].ToString())+1;
			}
			catch{ttm.Value=1;}
			tencot.Value=l_id=l_idm=0;
			ttc.Value=1;
			maso.Text=sttm.Text=ct.Text=maso.Text=tminh.Text=ghichu.Text=matg.Text=tinhtg.Text=dau.Text=mcode.Text="";
			nguondl.Text=fielddl.Text=dauc.Text=lk.Text=stk.Text=kmuc.Text=mtmuc.Text=nghiepvu.Text=hoatdong.Text=tkno.Text=kmno.Text=mtmno.Text=tkco.Text=kmco.Text=mtmco.Text="";
			indam.Checked=bc.Checked=false;
			dtc.Clear();
			ena_object(true);
			ttm.Focus();
		}

		private void butSua_Click(object sender, System.EventArgs e)
		{
			if (dt.Rows.Count==0) return;
			l_id=long.Parse(dataGrid1[dataGrid1.CurrentCell.RowNumber,0].ToString());
			ena_object(true);
			ttm.Focus();
		}

		private bool kiemtra()
		{
			if (ct.Text=="")
			{
				MessageBox.Show("Yêu cầu nhập chỉ tiêu !",a.Msg);
				ct.Focus();
				return false;
			}
			return true;
		}

		private void butLuu_Click(object sender, System.EventArgs e)
		{
			if (!kiemtra()) return;
			l_id=(l_id==0)?a.getIdmaubc():l_id;
			if (!a.upd_maubc(l_id,long.Parse(loai.SelectedValue.ToString()),ttm.Value,sttm.Text,ct.Text,maso.Text,tminh.Text,ghichu.Text,(indam.Checked)?"x":"",matg.Text,(tinhtg.Text!="")?int.Parse(tinhtg.Text):0,(dau.Text!="")?decimal.Parse(dau.Text):1,mcode.Text,(bc.Checked)?1:0,i_userid))
			{
				MessageBox.Show("Không cập nhật thông tin "+this.Text.Trim()+" !",a.Msg);
				return;
			}
			a.execute_data("delete from "+user+".a_congthuc where idbc="+l_id);
			foreach(DataRow r in dtc.Rows)
				a.upd_congthuc(long.Parse(r["id"].ToString()),l_id,decimal.Parse(r["tt"].ToString()),r["maso"].ToString(),r["nguondl"].ToString(),
					decimal.Parse(r["dau"].ToString()),r["fielddl"].ToString(),r["cthuc"].ToString(),decimal.Parse(r["tencot"].ToString()),
					r["stk"].ToString(),r["mtmuc"].ToString(),r["kmuc"].ToString(),r["lk"].ToString(),r["nghiepvu"].ToString(),r["hoatdong"].ToString(),
					r["tkno"].ToString(),r["mtmno"].ToString(),r["kmno"].ToString(),r["tkco"].ToString(),r["mtmco"].ToString(),r["kmco"].ToString(),i_userid);
			load_grid();
			ref_text();
			ref_text1();
			ena_object(false);
		}

		private void butBoqua_Click(object sender, System.EventArgs e)
		{
			ref_text();
			ena_object(false);
		}

		private void butHuy_Click(object sender, System.EventArgs e)
		{
			if (MessageBox.Show("Đồng ý hủy thông tin này !",a.Msg,MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
			{
				a.execute_data("delete from "+user+".a_maubc where id="+long.Parse(dataGrid1[dataGrid1.CurrentCell.RowNumber,0].ToString()));
				a.execute_data("delete from "+user+".a_congthuc where idbc="+long.Parse(dataGrid1[dataGrid1.CurrentCell.RowNumber,0].ToString()));
				load_grid();
			}
		}

		private void ref_text()
		{
			try
			{
				int i=dataGrid1.CurrentCell.RowNumber;
				l_id=long.Parse(dataGrid1[i,0].ToString());
				DataRow r=a.getrowbyid(dt,"id="+l_id);
				if (r!=null)
				{
					ttm.Value=decimal.Parse(r["tt"].ToString());
					sttm.Text=r["stt"].ToString();
					ct.Text=r["ct"].ToString();
					maso.Text=r["maso"].ToString();
					tminh.Text=r["tminh"].ToString();
					ghichu.Text=r["ghichu"].ToString();
					indam.Checked=r["indam"].ToString()=="x";
					matg.Text=r["matg"].ToString();
					tinhtg.Text=r["tinhtg"].ToString();
					dau.Text=r["dau"].ToString();
					mcode.Text=r["mcode"].ToString();
					bc.Checked=r["bc"].ToString()=="1";
				}				
			}
			catch{}
			load_ct();
		}

		private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
		{
			ref_text();
		}

		private void frmMaubc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.F10) butKetthuc_Click(sender,e);
		}

		private void stt_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter) SendKeys.Send("{Tab}");		
		}

		private void ct_Validated(object sender, System.EventArgs e)
		{
//			if (l_id==0 && ct.Text!="")
//			{
//				DataRow r1=a.getrowbyid(dt,"ct='"+ct.Text+"'");
//				if (r1!=null)
//				{
//					MessageBox.Show("Chỉ tiêu đã nhập !",a.Msg);
//					ct.Focus();
//				}
//			}
		}

		
		private void loai_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==loai) load_grid();
		}

		private void dataGrid2_CurrentCellChanged(object sender, System.EventArgs e)
		{
			ref_text1();
		}

		private void ref_text1()
		{
			try
			{
				l_idm=0;tencot.Value=0;
				nguondl.Text=fielddl.Text=dauc.Text=lk.Text=stk.Text=kmuc.Text=mtmuc.Text=nghiepvu.Text=hoatdong.Text=tkno.Text=kmno.Text=mtmno.Text=tkco.Text=kmco.Text=mtmco.Text="";
				int i=dataGrid2.CurrentCell.RowNumber;
				l_idm=long.Parse(dataGrid2[i,0].ToString());
				DataRow r=a.getrowbyid(dtc,"id="+l_idm);
				if (r!=null)
				{
					ttc.Value=decimal.Parse(r["tt"].ToString());
					tencot.Text=r["tencot"].ToString();
					dauc.Text=r["dau"].ToString();
					nguondl.Text=r["nguondl"].ToString();
					fielddl.Text=r["fielddl"].ToString();
					lk.Text=r["lk"].ToString();
					stk.Text=r["stk"].ToString();
					kmuc.Text=r["kmuc"].ToString();
					mtmuc.Text=r["mtmuc"].ToString();
					nghiepvu.Text=r["nghiepvu"].ToString();
					hoatdong.Text=r["hoatdong"].ToString();
					tkno.Text=r["tkno"].ToString();
					kmno.Text=r["kmno"].ToString();
					mtmno.Text=r["mtmno"].ToString();
					tkco.Text=r["tkco"].ToString();
					kmco.Text=r["kmco"].ToString();
					mtmco.Text=r["mtmco"].ToString();
				}
			}
			catch{}
		}

		private void butThem_Click(object sender, System.EventArgs e)
		{
			if (nguondl.Text!="")
			{
				l_idm=(l_idm==0)?a.getIdcongthuc():l_idm;
				DataRow r=a.getrowbyid(dtc,"id="+l_idm);
				if (r==null)
				{
					DataRow r1=dtc.NewRow();
					r1["id"]=l_idm;
					r1["idbc"]=l_id;
					r1["tt"]=ttc.Value;
					r1["maso"]="";
					r1["nguondl"]=nguondl.Text;
					r1["tencot"]=tencot.Value;
					r1["fielddl"]=fielddl.Text;
					r1["dau"]=(dauc.Text!="")?decimal.Parse(dauc.Text):1;
					r1["lk"]=lk.Text;
					r1["stk"]=stk.Text;
					r1["kmuc"]=kmuc.Text;
					r1["mtmuc"]=mtmuc.Text;
					r1["nghiepvu"]=nghiepvu.Text;
					r1["hoatdong"]=hoatdong.Text;
					r1["tkno"]=tkno.Text;
					r1["kmno"]=kmno.Text;
					r1["mtmno"]=mtmno.Text;
					r1["tkco"]=tkco.Text;
					r1["kmco"]=kmco.Text;
					r1["mtmco"]=mtmco.Text;
					dtc.Rows.Add(r1);
				}
				else 
				{
					DataRow [] dr=dtc.Select("id="+l_idm);
					if (dr.Length>0)
					{
						dr[0]["id"]=l_idm;
						dr[0]["idbc"]=l_id;
						dr[0]["tt"]=ttc.Value;
						dr[0]["maso"]="";
						dr[0]["nguondl"]=nguondl.Text;
						dr[0]["tencot"]=tencot.Value;
						dr[0]["fielddl"]=fielddl.Text;
						dr[0]["dau"]=(dauc.Text!="")?decimal.Parse(dauc.Text):1;
						dr[0]["lk"]=lk.Text;
						dr[0]["stk"]=stk.Text;
						dr[0]["kmuc"]=kmuc.Text;
						dr[0]["mtmuc"]=mtmuc.Text;
						dr[0]["nghiepvu"]=nghiepvu.Text;
						dr[0]["hoatdong"]=hoatdong.Text;
						dr[0]["tkno"]=tkno.Text;
						dr[0]["kmno"]=kmno.Text;
						dr[0]["mtmno"]=mtmno.Text;
						dr[0]["tkco"]=tkco.Text;
						dr[0]["kmco"]=kmco.Text;
						dr[0]["mtmco"]=mtmco.Text;
					}
				}
			}
			l_idm=0;tencot.Value=0;
			nguondl.Text=fielddl.Text=dauc.Text=lk.Text=stk.Text=kmuc.Text=mtmuc.Text=nghiepvu.Text=hoatdong.Text=tkno.Text=kmno.Text=mtmno.Text=tkco.Text=kmco.Text=mtmco.Text="";
			try
			{
				ttc.Value=decimal.Parse(dtc.Rows[dtc.Rows.Count-1]["tt"].ToString())+1;
			}
			catch{ttc.Value=1;}
			ttc.Focus();
		}

		private void butXoa_Click(object sender, System.EventArgs e)
		{
			a.delrec(dtc,"id="+l_idm);	
			dtc.AcceptChanges();
			ref_text1();
		}

		private void butLoai_Click(object sender, System.EventArgs e)
		{
			frmDmmaubc f=new frmDmmaubc(a,i_userid);
			f.ShowDialog();
			if (f.bUpdate)
			{
				load_maubc();
				load_grid();
			}
		}

		private void dau_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			a.MaskDigit_am(e);
		}

		private void dauc_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			a.MaskDigit_am(e);
		}

		private void tinhtg_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			a.MaskDigit(e);
		}

	}
}
